package com.kfm.pm;

import java.util.Arrays;
import java.util.Random;

public class BubbleSort {

    public static void sort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] < arr[j + 1]) {
                    arr[j] = arr[j] ^ arr[j + 1];
                    arr[j + 1] = arr[j] ^ arr[j + 1];
                    arr[j] = arr[j] ^ arr[j + 1];
                }
            }
        }
    }

    public static void main(String[] args) {
        //
        int[] nums = {2, 4, -1, 0, 9,8};
        sort(nums);
//        Arrays.sort(nums);
        for (int num : nums) {
            System.out.println(num);
        }
    }
}
